package cn.ahaiahaixx.dp.thread;

import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.Scanner;

public class UrlRunnable implements Runnable {

  private String url;

  public UrlRunnable(String url) {
    this.url = url;
  }

  @Override
  public void run() {
    try {
      
      URLConnection connection = new URL(url).openConnection();
      InputStream is = connection.getInputStream();
      Scanner scanner = new Scanner(is);
      while (scanner.hasNext()) {
        System.out.println(scanner.nextLine());
      }
      scanner.close();
      is.close();
      
    } catch (Exception e) {

    }

  }

}
